package com.whfc.ms.api.base.controller;

import com.whfc.base.dto.WeatherDTO;
import com.whfc.common.base.BaseController;
import com.whfc.common.result.R;
import com.whfc.entity.dto.warn.WarnCountDTO;
import com.whfc.ms.api.base.service.ProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 小程序2.0首页
 * @author ：pyl
 * @date ：Created in 2022/7/18 14:07
 * @description：小程序2.0首页
 */

@RestController
@RequestMapping("/ms/api/home")
public class HomePageController extends BaseController {

    @Autowired
    private ProjectService projectService;

    /**
     * 2.0 获取实时天气情况
     * @param deptId
     * @return
     */
    @GetMapping("weather")
    public R<WeatherDTO> realtimeWeather(@RequestParam("deptId") Integer deptId) {
        logger.info("获取实时天气");
        return R.success(projectService.realtimeWeather(deptId));
    }


    /**
     * 2.0 获取监控报警数量
     * @param deptId
     * @return
     */
    @GetMapping("warn/list")
    public R<WarnCountDTO> warnList(@RequestParam("deptId") Integer deptId) {
        logger.info("获取监控报警数量入参机构id:{}",deptId );
        WarnCountDTO appProjectDetailDTO = projectService.warnList( deptId);
        return R.success(appProjectDetailDTO);
    }

}
